<%-- 
    Document   : db1
    Created on : 2014/8/19, 下午 01:28:56
    Author     : gjun
--%>

<%@page import="java.sql.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
    String id= request.getParameter("id");//抓取id值
    //import時 注意要java.sql.的開頭
    Class.forName("com.mysql.jdbc.Driver");//載入資料庫驅動程式
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/javadb","root","root") ;
          //  .getConnection(Services頁-內的database的connection內的URL,帳號,密碼)
    Statement st= con.createStatement();
    String sql="delete from person where id="+id;
          
    int x= st.executeUpdate(sql);//executeUpdate(sql)新增了資料幾筆(算此次動了幾筆資料)
    st.close();//關st
    
    con.close();//關閉con
    
       
%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>資料已刪除</h1>
        刪除第<%= id %>資料<br>
        刪了<%= x %>資料<br>
        <a href="list.jsp">回清單檢視</a>
    </body>
</html>
